package com.example.demo8;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;

public class Projectile {
    public double x, y;
    public double dx, dy;
    public int damage;
    public boolean isEnemyProjectile;

    public Projectile(double x, double y, double dx, double dy, int damage, boolean isEnemyProjectile) {
        this.x = x;
        this.y = y;
        this.dx = dx;
        this.dy = dy;
        this.damage = damage;
        this.isEnemyProjectile = isEnemyProjectile;
    }

    // 更新子弹的位置
    public void update() {
        x += dx;
        y += dy;
    }

    // 绘制子弹
    public void draw(GraphicsContext gc) {
        gc.setFill(isEnemyProjectile ? Color.RED : Color.BLUE);
        gc.fillOval(x - 4, y - 4, 8, 8);  // 设置子弹大小
    }
}
